import {getLocal} from './localstore'

const service = axios.create({
  timeout: 5000 // 请求超时时间

})

service.interceptors.request.use(
  (config) => {
    let token = getLocal('token')
    // 在请求拦截中，每次请求，都会加上一个Authorization头
    config.headers.Authorization = `Bearer ${token}`
    config.headers.token = token
    return config;
  }
)

service.interceptors.response.use(
  response => {
    return response
  },
  error => {
    console.log(error)
  },
)

export default  service
